package com.mz.ozy.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.mz.ozy.R;

public class UpdateVersionDialog extends Dialog {
    private Context mContext;
    CheckDialog.OnClickListener mOnClickListener;
    private String content;
    private String btStr;

    public UpdateVersionDialog(Context context, String content, CheckDialog.OnClickListener mOnClickListener) {
        super(context, R.style.dialogtheme);
        this.mContext = context;
        this.content = content;
        this.mOnClickListener = mOnClickListener;
    }

    public UpdateVersionDialog(@NonNull Context context, String content, String btStr, CheckDialog.OnClickListener mOnClickListener) {
        super(context, R.style.dialogtheme);
        this.mContext = context;
        this.content = content;
        this.btStr = btStr;
        this.mOnClickListener = mOnClickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_update_version, null);
        setContentView(view);
        setCanceledOnTouchOutside(false);
        setCancelable(false);

        final TextView tvContent = view.findViewById(R.id.tv_content);
        final TextView tvTitle = view.findViewById(R.id.tv_title);
//        webView.loadDataWithBaseURL(null, Utils.getNewContent(content), "text/html", "utf-8", null);
        tvTitle.setText(content);
        tvContent.setText(btStr);
        view.findViewById(R.id.bt_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mOnClickListener != null) {
                    mOnClickListener.onClick();
                }
            }
        });
        view.findViewById(R.id.iv_msg_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public interface OnClickListener {
        void onClick();
    }
}
